﻿<KCtl:BaseUserControl xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"  
                      x:Class="Kiva7.Pages.LoansAndDetailControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:KCtl="clr-namespace:Kiva7.Controls" xmlns:my="clr-namespace:Kiva7.Pages"
                      mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480"
    KCtl:TiltEffect.IsTiltEnabled="True" Loaded="BaseUserControl_Loaded">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="240"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        
        <ListBox x:Name="lbxLoans" 
                 Grid.Column="0"
                 Margin="0,0,-12,0" ItemsSource="{Binding Data}" 
                 Background="{StaticResource KivaBackgroundBrush}"
                 HorizontalContentAlignment="Stretch" SelectionChanged="lbxLoans_SelectionChanged">

            <ListBox.ItemTemplate>

                <DataTemplate>

                    <StackPanel Margin="0,0,0,18">

                        <Grid>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="78" ></ColumnDefinition>
                                <ColumnDefinition Width="162" ></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                            <StackPanel Style="{StaticResource KivaListItemImageStyle}">
                                <KCtl:KivaImageControl x:Name="imgLender" ImageSize="Small" ImageData="{Binding Image}" Width="78" Height="78" 
                                    VerticalAlignment="Top" HorizontalAlignment="Center"
                                       Grid.Column="0"
                                    Visibility="{Binding Image, Converter={StaticResource objectVisibility}}" Margin="0,12,0,0" />
                            </StackPanel>
                            
                            <StackPanel Grid.Column="1" Style="{StaticResource KivaListItemStyle}">
                                
                                <TextBlock Text="{Binding Name}" TextWrapping="Wrap" 
                                    Style="{StaticResource KivaTextAccentStyle}"/>

                                <toolkit:WrapPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Location.Country}"
                                   Style="{StaticResource KivaTextSmallStyle}"/>
                                </toolkit:WrapPanel>
                                
                            </StackPanel>
                        </Grid>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

        <ProgressBar Maximum="{Binding PagesCount}" 
                     Value="{Binding PagesLoaded}" 
                     VerticalAlignment="Top" 
                     Height="12" 
                     Visibility="{Binding PagesLoading, Converter={StaticResource booleanToVisibility}}"
                     Grid.Column="0"/>

        <Grid Grid.Column="1" x:Name="loanDetail">
            <my:LoanAndDetailControl x:Name="LoanImageControl1" />
        </Grid>
        
    </Grid>
</KCtl:BaseUserControl>
